<!--
  - Copyright (c) 2018.
  - 北京九思金信科技有限公司对该文件内容保留所有权利。
  - 未经许可，不得私自拷贝、传播、发布、引用该文件内容，违者将被追究法律责任。
  -->
  <template>
  <div class="sueSearch_box">
    <div class="sueSearch_title">
      <div class="search_box">
        <img
          src="@/pages/mobile/assets/img/Back@3x.png"
          @click="returnHistoy"
          alt
        />
        <input
          type="text"
          placeholder="搜索报价测算名称"
          maxlength="20"
          v-model="searchInfo"
        />
      </div>
      <i @click="returnHistoy">取消</i>
    </div>
    <scroll class="QuoteCalculateSearch_scroll">
      <div class="QuoteCalculateSearch_content">
        <div
          class="QuoteCalculateSearch_content_item"
          v-for="item in searchlist"
          @click="quoteCalculateItemInfo(item.quoteCalculatorId)"
        >
          <div class="QuoteCalculateSearch_content_item_data">
            <p>{{ item.quoteName }}</p>
            <span>{{ item.financingAmount }}</span>
          </div>
          <div class="QuoteCalculateSearch_content_item_details">
            <i>查看详情</i>
            <x-icon
              class="details_img"
              type="ios-arrow-forward"
              size="23"
            ></x-icon>
          </div>
        </div>
      </div>
    </scroll>
    <div v-if="!searchlist.length && searchInfo" class="sueSearch_none_list">
      没有搜索到任何关于“{{ searchInfo }}”的报价测算
    </div>
    <div v-show="!searchlist.length && !searchInfo" class="sueSearch_none_list">
      搜索报价测算
    </div>
  </div>
</template>
  
  <script>
import Scroll from "@/pages/mobile/assets/js/JoysScroll/JoysScroll";
import { myDOM } from "@/pages/mobile/assets/js/utils.js";
export default {
  name: "QuoteCalculateSearch",
  components: {
    Scroll
  },
  data () {
    return {
      searchInfo: "",
      searchlist: []
    };
  },
  methods: {
    searchInfoList () {
      this.$axios({
        method: "post",
        url: "/joys-rest/joys-calculate/calculator/list/page",
        headers: {
          "AUTH-TOKEN": localStorage.getItem("AUTH-TOKEN"),
          "Content-Type": "application/json;charset=UTF-8"
        },
        params: {
          pageIndex: 1,
          pageSize: 10000
        },
        data: this.searchInfo
      })
        .then(res => {
          this.searchlist = res.data.rows;
        })
        .catch(error => {
          console.log(error);
        });
    },
    // 查看信息
    quoteCalculateItemInfo (id) {
      this.$router.push({
        path: '/calculator/quoteCalculateResult',
        query: {
          id: id
        }
      })
    },

    returnHistoy () {
      this.$router.goBack();
    }
  },
  created () {
    // 节流
    this.$watch(
      "searchInfo",
      myDOM.debounce(newQuery => {
        this.searchInfoList();
      }, 300)
    );
  }
};
</script>
  
  <style scoped lang="less">
.sueSearch_box {
  position: fixed;
  top: 0rem;
  bottom: 0.1rem;
  width: 100%;
  height: 100%;
  z-index: 300;
  background: #ffffff;
  .sueSearch_title {
    height: 0.44rem;
    width: 100%;
    background: #ffffff;
    box-shadow: inset 0 -1px 0 0 rgba(207, 207, 207, 0.2);
    position: relative;
    overflow: hidden;
    .search_box {
      position: absolute;
      top: 0rem;
      left: 0rem;
      width: 100%;
      line-height: 0.44rem;
      height: 0.44rem;
      img {
        width: 0.2rem;
        position: absolute;
        // left: 0.085rem;
        // top: 0.12rem;
        top: 0rem;
        left: 0rem;
        padding: 0.12rem 0.085rem;
      }
      input {
        padding-left: 0.1rem;
        height: 0.32rem;
        background: rgba(141, 141, 141, 0.05);
        font-family: Regular;
        font-size: 0.14rem;
        color: #001616;
        letter-spacing: -0.34px;
        line-height: 0.14rem;
        margin-top: -0.05rem;
        margin-left: 0.36rem;
        width: 100%;
      }
      input::placeholder {
        font-family: Regular;
        font-size: 0.14rem;
        color: #c6c6c6;
        letter-spacing: -0.34px;
        line-height: 0.14rem;
      }
    }
    i {
      display: block;
      height: 0.43rem;
      width: 0.63rem;
      line-height: 0.44rem;
      text-align: center;
      font-family: Regular;
      font-size: 0.14rem;
      color: #001616;
      letter-spacing: -0.34px;
      position: absolute;
      top: 0rem;
      right: 0rem;
      background: #ffffff;
    }
  }
  .QuoteCalculateSearch_scroll {
    overflow: hidden;
    top: 0.44rem;
    .QuoteCalculateSearch_content {
      margin: 0 0.16rem;
      padding-top: 0.1rem;
      padding-bottom: 0.1rem;
      .QuoteCalculateSearch_content_item {
        margin-top: 0.1rem;
        background: #ffffff;
        box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.06);
        border-radius: 5px;
        // height: 0.91rem;
        padding: 0.12rem 0.12rem 0.1rem 0.12rem;
        .QuoteCalculateSearch_content_item_data {
          height: 0.66rem;
          border-bottom: 1px solid #eeeeee;
          p {
            font-family: PingFangSC-Regular;
            font-size: 0.14rem;
            color: #443a38;
            letter-spacing: 0;
            height: 0.2rem;
            line-height: 0.2rem;
          }
          span {
            font-family: PingFangSC-Semibold;
            font-size: 0.24rem;
            color: #e5a83f;
            letter-spacing: 0.67px;
            height: 0.4rem;
            line-height: 0.4rem;
          }
        }
        .QuoteCalculateSearch_content_item_details {
          padding-top: 0.1rem;
          height: 0.22rem;
          display: flex;
          align-items: center;
          i {
            font-family: PingFangSC-Regular;
            font-size: 0.12rem;
            color: #9c9795;
            letter-spacing: -0.29px;
            line-height: 0.14rem;
          }
          .vux-x-icon {
            fill: #d1d1d6;
          }
          .details_img {
            position: absolute;
            right: 0.24rem;
          }
        }
      }
      .QuoteCalculateSearch_content_item:nth-child(2n) {
        .QuoteCalculateSearch_content_item_data {
          span {
            color: rgba(23, 42, 136, 0.8);
          }
        }
      }
      .QuoteCalculateSearch_content_item:first-child {
        margin-top: 0rem;
      }
    }
  }
  .sueSearch_none_list {
    font-family: Regular;
    font-size: 0.13rem;
    color: rgba(0, 22, 22, 0.8);
    letter-spacing: 0;
    text-align: center;
    margin-top: 30%;
  }
}
</style>
